#include "../../lib/List.h"
#include <iostream>
#include <string>

int main() {
    // 创建一个字符串类型的List适配器
    List<std::string> list;

    // Java风格的添加操作
    list.add("Hello");
    list.add("World");
    list.add("C++");

    std::cout << "List size: " << list.size() << std::endl;        // 输出: 3
    std::cout << "Is empty: " << list.isEmpty() << std::endl;     // 输出: 0 (false)

    // Java风格的元素访问
    std::cout << "First element: " << list.get(0) << std::endl;  // 输出: Hello
    std::cout << "Last element: " << list.get(list.size()-1) << std::endl; // 输出: C++

    // Java风格的插入和删除
    list.add(1, "Beautiful");  // 在索引1处插入
    std::cout << "After insert at index 1: ";
    for (size_t i = 0; i < list.size(); ++i) {
        std::cout << list.get(i) << " ";
    }
    std::cout << std::endl;  // 输出: Hello Beautiful World C++

    // 删除指定位置的元素
    std::string removed = list.remove(2);  // 删除索引2的元素
    std::cout << "Removed element: " << removed << std::endl;  // 输出: World

    // 使用C++11的范围for循环
    std::cout << "Final elements: ";
    for (const auto& element : list) {
        std::cout << element << " ";
    }
    std::cout << std::endl;  // 输出: Hello Beautiful C++

    return 0;
}